package cn.donting.jme.editor;

import cn.donting.jme.JmeApplication;
import cn.donting.jme.swing.Tab;
import com.jme3.scene.Node;

import javax.swing.*;
import java.util.List;

public interface EditorUI {

    JTabbedPane getJTabbedPane1();

    JTabbedPane getJTabbedPane2();

    JTabbedPane getJTabbedPane3();

    JTabbedPane getJTabbedPane4();

    JmeApplication getJmeApplication();

    default Node getEditorNode() {
        return getJmeApplication().getEditorNode();
    }

    default Node getSceneNode() {
        return getJmeApplication().getSceneNode();
    }

    void addTab(int index, Tab tab);

    <T extends Tab> T getTab(int index, Class<T> t);

    default <T extends Tab> T getTabOfAdd(int index, Class<T> tClass) {
        T tab = getTab(index, tClass);
        if (tab == null) {
            try {
                tab = tClass.newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            addTab(index, tab);
        }
        return tab;
    }

    List<Tab> getTabs(int index);


}
